<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function getname(){
            return new Promise((resolve,reject)=>{
                console.log('开始请求姓名')
               try{ 
                setTimeout(()=>{
                   console.log('请求姓名成功')
                   const username={
                        name:'高雅琳'
                   }
                   resolve(username)

                },2000)
            }catch(e){
                reject(e.message)
                }
            })

        }

        function getage(username){
            return new Promise((resolve,reject)=>{
                console.log('开始请求年龄')
               try{ 
                setTimeout(()=>{
                   console.log('请求年龄成功')
                   const age={
                        age:18
                   }
                   resolve({...username,...age})

                },2000)
            }catch(e){
                reject(e.message)
                }
            })

        }
        function getSex(age){
            return new Promise((resolve,reject)=>{
                console.log('开始请求性别')
               try{ 
                setTimeout(()=>{
                   console.log('请求性别成功')
                   const sex={
                        sex:'女'
                   }
                   resolve({...age,...sex})

                },2000)
            }catch(e){
                reject(e.message)
                }
            })

        }

         async function getData(){
            const username = await getname()
            const age = await getage(username)//要传参
            const sex = await getSex(age)
            console.log('完整数据',sex)
        }
           
        getData()         
              


    </script>
</body>
</html>